package spring.cloud.tasks.executor.name_space;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.zookeeper.data.Stat;

import java.util.List;

public interface NameSpaceDataManager {

    String getNameSpace();

    void init();

    boolean isConnected();

    CuratorFramework getCuratorFramework();

    void close();

    //
    long getCtime(String path);

    Stat getStat(final String path);

    String getExecutorId();

    //
    void setExecutorId(String executorId);
    //

    /**
     * 添加连接状态变更事件监听
     */
    void addConnectionStateListener(ConnectionStateListener connectionStateListener);

    /**
     * 删除连接状态变更事件监听
     */
    void removeConnectionStateListener(ConnectionStateListener connectionStateListener);

    /**
     * 持久化数据.
     */
    void createIfNeedOrSetData(String path, String value);

    /**
     * 更新注册数据.
     */
    void setData(String path, String value);

    /**
     * 持久化临时数据.
     */
    void createEphemeralDataNode(String path, String value);

    /**
     * 持久化临时顺序注册数据.
     */
    void createEphemeralSequentialDataNode(String path);

    /**
     * 删除注册数据.
     *
     * @param path 键
     */
    void delete(String path);

    /**
     * 获取数据是否存在.
     */
    boolean checkExists(String path);

    /**
     * 获取注册数据.
     */
    String getData(String path);

    /**
     * 获取子节点名称集合.
     */
    List<String> getChildrenList(String path);

}
